package server;
import java.sql.*;
public class Data{
	private Connection conn;
	
	public Data(){
		try{
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/javavirtualcity","root","helloworld");//("jdbc:mysql://88.198.43.24:3306/javavirtualcity","javavirtualcity","javacity");
		} catch (Exception e) 
		{
			e.printStackTrace();
		}
	}
	
	/*public Connection getConn(){
		return conn;
	}*/
	
	public ResultSet getResultSet(String sql){
		Statement stmt;
		ResultSet res=null;
		
		try {
			stmt = conn.createStatement();
			res = stmt.executeQuery(sql);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
	    return res;
	}
	
	public int update(String sql){
		Statement stmt;
		int re=0;
		
		try {
			stmt = conn.createStatement();
			re = stmt.executeUpdate(sql);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
	    return re;
	}
}